<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Models\CourseClass;
use App\User;
use Illuminate\Support\Facades\Redis;
class CreateRegisterUserPushMessage extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'create:register_user_message {id} {cid}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '模拟数据添加用户信息及推送课程信息';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $id = $this->argument('id');
        $cid = $this->argument('cid');
        $user = User::where('id',$id)->first();

        $course = CourseClass::where('id',$cid)->first();
        Redis::set('subscribe_user_push_'.$user->id,json_encode($user));
        Redis::set('push_course',json_encode($course));

        $this->info(Redis::get('push_course').'--'.Redis::get('subscribe_user_push_'.$user->id));
    }
}